Pebble CDEF Tester Read Me:
===========================


Pebble CDEF Tester Instructions:
--------------------------------

When the program starts, a window will appear with a single control in it (at
co-ordinates 10,10).  The window may be moved anywhere on the screen; menubar
commands are ignored.  If the window is closed, the program quits.

The control responds in the following ways:

	Clicking the active control tests the control.  If the button is released
	within the control, a beep will sound; otherwise nothing will happen.  If an
	inactive control is pressed, nothing will happen.

 Tapping or holding a key will toggle the control's state: active or inactive.
	If the control is inactive, only it's outline is drawn; if the control is
	active, the entire control is drawn.

 If the window is de-activated (i.e. the window is no longer the front window
	because the user switched to some other program), the control will also
	de-activate. If the window is activated (the user switched back to the
	program) the control is activated.

To quit the program, click the window's GoAway box.


General CDEF Notes:
-------------------

This CDEF can be used to represent "Push Buttons" as well as "Stored State
Buttons" like Check Boxes and Radio Buttons.  The only real difference (AFAIK)
between these two kinds of controls is:  Push Buttons' non-zero value looks the
same as the tracking indicator; Radio Buttons'/Check Boxes' non-zero value looks
different than the tracking indicator.  For example, when you push a Push Button,
the center inverts itself. When you click in a Radio Button, before you let go,
the button grows a little darker; it is only after you click in the Radio Button
that the center fills in completely.

Confused? Go open a control panel and mess around with the controls. You'll see
what I mean.

The CDEF (Control Definition) uses PICTs to define the "Normal" and "Selected"
views of the button.  The Resource IDs of the PICTs are passed to the CDEF in the
contrlMin ("Normal") and contrlMax ("Selected") fields of the ControlRecord. Both
PICTs should be the same size.  The "Normal" PICT is the view of the Active
control; the "Selected" PICT is the view of the control when a user clicks in the
control.  

	NOTE: While the CDEF assumes both PICTs have the same dimensions, only the
		  picFrame of the first pict ("Normal") is used in calculating the 
		  control's bounding Rect.

If the Control was created as a "Stored State Button" (varCode = 1), then the
"Normal" and "Selected" views only reflect static states; a different graphic
technique is used for tracking the control.   When the user clicks in the
control, but before the user lets go of the button, the control's current view is
hilighted. This represents tracking.  The actual hilighting process is VERY
obfuscated; it will not change.  Once the user lets go of the mouse button within
the control, it is up to the program to change the value of the control (as
usual).

When the control is deactivated, the CDEF simply draws an empty rectangle in
place of the "Normal" PICT.  Thus, the CDEF assumes the control completly fills
it's rectangular bounds.

In a Black and White window, only the first PICT is used.  The PICT is inverted
for tracking and for reflecting state. Thus, "Push Buttons" and "Stored State 
Buttons" are identical in Black and White; it is up to the application to
maintain the abstraction.
	
	
Gory CDEF Details:
------------------

When the control is created, the bounding rect should have its left and top field
set to the control's upper left corner in the owning window's local coordinates:

	SetRect(&boundingRect, LeftPosition, TopPosition, 0, 0);

Any value for right and bottom can be used; the bounding rectangle is resized by
the CDEF when the control is created to match the dimensions of the PICTs. Again,
set min and max to the ResIDs of the "Normal" and "Selected" PICTs.  Use a
control type of (ResID << 4) + varCode, with varCode = 0 for "Push Buttons" and
varCode = 1 for "Stored State Buttons".

Once the PICTs are loaded, contrlMin and contrlMax are set to 0 and 1
respectively. if contrlValue is initially set between 0 and 1, it's value will be
preserved.

When the control is deactivated within a Color window, it is drawn as a grey
rectangle framed in black. The exact grey color used is:

	RGBColor grey = {0xEEEE, 0xEEEE, 0xEEEE};

If the control is deactivated in a Black and White window, it's bound rect is
simply erased and then framed.

For those who MUST know, "Stored State Button" tracking-highlighting is handled
in the following way:

	If the control is in a Black and White window, draw the "Normal" PICT in the
	bounding rectangle, inset the bounding rectangle 1 pixel in all directions
	("OffsetRect(&r,1,1);"), invert the pixels in the bounding rectangle. Done!

	If the control is in color, draw the appropriate PICT.

	If the control's value == 0, darken all grey=0xEEEE pixels (0xEEEE->0xAAAA).

	Otherwise, if the control's value == 1, darken all grey=0xDDDD pixels
	(0xDDDD->0xAAAA).

It is up to the Program to provide "Normal" pictures primarily composed of
grey=0xEEEE and "Selected" pictures primarily composed of grey=0xDDDD.


=========
M Trent
19 Mar 95
